'Lab #11 'for IT310 'due by 04/13/01 'from Maksim Ivanenko 'pg VB458 ex#3 Option Explicit Private Sub cmdExit_Click() 'to end run End End Sub Private Sub cmdPrint_Click() 'to make printout without command buttons cmdDisplay.Visible = False cmdExit.Visible = False cmdPrint.Visible = False PrintForm cmdDisplay.Visible = True cmdExit.Visible = True cmdPrint.Visible = True End Sub Private Sub Form_Load() 'declaring type Dim msg As String, inv As String, accum As Single Dim price As Single, quant As Integer, average As Single, Count As Integer 'open data file Open "a:\Home work\Lab11.txt" For Append As #1 'this is optional message to prompt for beginning of input process msg = MsgBox("Please Enter Inventory.", vbOKCancel, "Inventory") 'input data from user Do While msg <> "" 'assigning abbriviated variables inv = InputBox("Enter Inventory Number", "Inventory") quant = Val(InputBox("Enter quantity", "Quantity")) price = Val(InputBox("Enter units Price", "Price")) 'recording input to disk Write #1, inv, quant, price 'condition to exit input loop msg = InputBox("Would you like to continue? If so , press any key. Hit cancel to exit.", "Inventory process.") 'to continue inventory audition Loop 'close data file Close #1 'declaring types Dim Inventory As String, Quantity As String, Prices As String 'accessing file for reading Open "a:\Home work\Lab11.txt" For Input As #1 'loop condition to read all available info on a disk Do While Not EOF(1) 'reading file data Input #1, inv, quant, price 'counter Count = Count + quant 'accumulator accum = accum + quant * price 'accumulating info for future display Inventory = Inventory & " " & inv Quantity = Quantity & " " & quant Prices = Prices & " " & FormatCurrency(price) Loop 'closing file Close #1 'calculating average per unit average = accum / Count 'displaying average result in currency format txtAverage.Text = FormatCurrency(average) 'displaying results txtInventory.Text = Inventory txtQuantity.Text = Quantity txtPrice.Text = Prices End Sub